package com.cn.web.bean;

import cn.com.allunion.common.page.QueryResult;
import cn.com.allunion.sms.pojo.Smsbusiness;
import cn.com.allunion.sms.pojo.Smsoperator;
import com.alibaba.fastjson.annotation.JSONField;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 对接业务结果集
 * Created by YangJie on 2016/4/20.
 */
public class BusinessResult {
    @JSONField(name = "businessId")
    private String smsBusinessID;

    private String businessCode;

    @JSONField(name = "status")
    private String businessState;

    @JSONField(name = "businessDesc")
    private String smsBusinessDesc;

    @JSONField(name = "businessName")
    private String smsBusinessName;

    private String businessJoinNum;

    private String businessSignature;

    /**
     * 将对接业务实体对象转化为返回结果集对象
     * @param smsbusiness 业务实体对象
     * @return 返回结果集对象
     */
    public static BusinessResult convert(Smsbusiness smsbusiness) {
        if (null == smsbusiness) {
            return null ;
        }
        BusinessResult result = new BusinessResult() ;
        BeanUtils.copyProperties(smsbusiness, result);
        return result;
    }

    /**
     * 将Smsbusiness集合转换为OperatorResult集合
     * @param smsbusinesses 待转换的集合对象
     * @return 转换后的结果
     */
    public static List<BusinessResult> convert(List<Smsbusiness> smsbusinesses) {
        if (null == smsbusinesses) {
            return null ;
        }
        List<BusinessResult> businessResults = new ArrayList<>(smsbusinesses.size()) ;
        BusinessResult result ;
        for (Smsbusiness sb : smsbusinesses) {
            result = new BusinessResult() ;
            BeanUtils.copyProperties(sb, result);
            businessResults.add(result);
        }

        return businessResults ;
    }

    /**
     * 将queryResult分解结果集合转换为SmsoperatorResult分页结果集合
     * @param queryResult 待转换的分页集合对象
     * @return 转换后的结果
     */
    public static QueryResult<BusinessResult> convert(QueryResult<Smsbusiness> queryResult) {
        if (null == queryResult) {
            return null ;
        }
        return new QueryResult<BusinessResult>(convert(queryResult.getResultList()), queryResult.getTotalRecord()) ;
    }

    public String getSmsBusinessID() {
        return smsBusinessID;
    }

    public void setSmsBusinessID(String smsBusinessID) {
        this.smsBusinessID = smsBusinessID;
    }

    public String getBusinessCode() {
        return businessCode;
    }

    public void setBusinessCode(String businessCode) {
        this.businessCode = businessCode;
    }

    public String getBusinessState() {
        return businessState;
    }

    public void setBusinessState(String businessState) {
        this.businessState = businessState;
    }

    public String getSmsBusinessDesc() {
        return smsBusinessDesc;
    }

    public void setSmsBusinessDesc(String smsBusinessDesc) {
        this.smsBusinessDesc = smsBusinessDesc;
    }

    public String getSmsBusinessName() {
        return smsBusinessName;
    }

    public void setSmsBusinessName(String smsBusinessName) {
        this.smsBusinessName = smsBusinessName;
    }

    public String getBusinessJoinNum() {
        return businessJoinNum;
    }

    public void setBusinessJoinNum(String businessJoinNum) {
        this.businessJoinNum = businessJoinNum;
    }

    public String getBusinessSignature() {
        return businessSignature;
    }

    public void setBusinessSignature(String businessSignature) {
        this.businessSignature = businessSignature;
    }
}
